


import java.util.ArrayList;
import java.util.List;

/**
 * This class creates medical history. It takes in an ArrayList of treatment
 * records and the patient health history.
 * 
 * @author evelyn942
 * @version 1.0 3-10-11
 */

public class MedicalHistory {

	/**
	 * This instance variable instantiates a list of treatmentRecord. The
	 * TreatmentRecord list makes up the Medical History class.
	 */
	private final List<TreatmentRecord> treatmentRecords;

	/**
	 * This is the constructor for the class. It instantiates the array list of
	 * treatment records to make the medical history class. Each patient will
	 * have a treatment record for every visit. This class is just the
	 * compliation of those records.
	 */
	public MedicalHistory() {
		treatmentRecords = new ArrayList<TreatmentRecord>();
	}

	/**
	 * This method adds a treatmentRecord from the Treatment record class to the
	 * medical history.
	 * 
	 * @param record
	 *            This parameter is of type TreatmentRecord. It is pulled in and
	 *            added to the front of the array list at spot zero.
	 */
	public void addTreatmentRecord(TreatmentRecord record) {
		if(record != null){
			treatmentRecords.add(0, record);
		}
	}

	/**
	 * This method pulls out the newest treatment record and returns it in the
	 * form of a Treatment Record to be accessed by the users. Doctors and
	 * nurses can access the newest treatment records for reference
	 * 
	 * @return treatmentRecord at the beginning of the array. TRs are stored
	 *         from newest (spot 0) to oldest (last spot). easy reference for
	 *         all users
	 */
	public TreatmentRecord getNewestTreatment() {
		return treatmentRecords.get(0);
	}

	/**
	 * This method returns a full list of all the treatment records from the
	 * array list to be viewed/accessed by users.
	 * 
	 * @return treatmentRecord list. Pulls out the arrayList into a list of all
	 *         the records entered in; used by all users and database
	 */
	public List<TreatmentRecord> getTreatmentRecords() {
		return treatmentRecords;
	}

	/**
	 * This is the toString method for the treatment Records. It returns the
	 * list of treatment records for a patient.
	 * 
	 * @return treatment record
	 */
	public String toString() {
		String str = "MEDICALHISTORY\n~~~~~~~~~~~~~";
		List list = getTreatmentRecords();
		for(int i = 0; i < list.size(); i++){
			if(list.get(i) != null){
				str += "\n\n" + list.get(i).toString();
			}
		}
		return str;
	}
}